using System;
using System.Runtime.Serialization;
using System.Text;
namespace MINERP.COM
{
    [Serializable]
    public class CustomMsgException : Exception
    {

        #region "Member Variables"
        const string _className = "CustomMsgException";
        const int _hresult = -2146232832;
        #endregion

        #region "Constructors"
        public CustomMsgException()
            : base()
        {
            base.HResult = _hresult;
        }

        public CustomMsgException(string message)
            : base(message)
        {
            base.HResult = _hresult;
        }

        public CustomMsgException(string message, Exception innerException)
            : base(message, innerException)
        {
            base.HResult = _hresult;
        }

        protected CustomMsgException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            base.HResult = _hresult;
        }
        #endregion

        #region "Properties & Operators"
        public static implicit operator string(CustomMsgException ex)
        {
            return ex.ToString();
        }
        #endregion

        #region "Methods"
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0}: {1}", _className, this.Message);
            if (this.InnerException != null)
            {
                sb.AppendFormat(" ---> {0} <---", base.InnerException.ToString());
            }

            if (this.StackTrace != null)
            {
                sb.Append(Environment.NewLine);
                sb.Append(base.StackTrace);
            }

            return sb.ToString();
        }

        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
        }

        #endregion

    }

}